from flask import Flask, render_template, request
from flask_bootstrap import Bootstrap
from flask_moment import Moment

from form import UploadForm
import parse

app = Flask(__name__)
app.config["SECRET_KEY"] = 'seven'
bootstrap = Bootstrap(app)
moment = Moment(app)

@app.route('/' or '/up', methods=['POST', 'GET'])
def hello_world():
    form = UploadForm()
    if request.method == 'POST' and form.validate_on_submit():
        macs = form.macs.data
        macs = macs.split('\r\n')
        # print("===>",macs)
        data = parse.walk_all(macs)
        return render_template('home.html', datas=data, form=form)
    return render_template('home.html', form=form)


if __name__ == '__main__':
    app.run()
